#include<bits/stdc++.h>
using namespace std;

string s[110];

int main()
{
	string a, b, t;
    getline(cin, t);
    cin>>a>>b;
    int len = t.size() , k = 0;
    for(int i = 0;i < len;i++)
    {
    	if(t[i] != ' ')
    		s[k] += t[i];
    	else
    		k++;
	}
	for(int i = 0;i <= k;i++)
	{
		if(s[i] == a)
			s[i] = b;
		cout<<s[i]<<" ";
	}
	return 0;
}

